package zhtt.jpa.hibernate.dao;

import org.springframework.stereotype.Repository;
import zhtt.jpa.hibernate.entity.User;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import java.util.List;

/**
 * Created by ztt on 2018/3/17.
 */
@Repository
public class UserRepository {

    @PersistenceContext
    private EntityManager entityManager;

    public List<User> findAll() {
        return (List<User>) entityManager.createQuery("select s from User s").getResultList();
    }
}
